package gui.data.D2;

import gui.MyFrame;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class TriangleOutputGui extends JPanel {
	JTextField abInput, bcInput, caInput, abHeightInput, bcHeightInput, caHeightInput, cabAngleInput,
			abcAngleInput, bcaAngleInput, circumfInput, areaInput;
	MyFrame myFrame;
	JLabel abLbl, bcLbl, caLbl, abHeightLbl, bcHeightLbl, caHeightLbl, cabAngleLbl, abcAngleLbl,
			bcaAngleLbl, circumfLbl, areaLbl;
	int selection = 3;

	public TriangleOutputGui(int guide, double abLength, double bcLength,
			double caLength, double abHeight, double bcHeight, double caHeight,
			double cabAngle, double abcAngle, double bcaAngle,
			double circumference, double area) {
		this.setLayout(new GridLayout(0, 2));
		this.setPreferredSize(new Dimension(500, 500));

		ButtonGroup group = new ButtonGroup();

		JRadioButton equilateralTriangle = new JRadioButton("Equilateral");
		equilateralTriangle.setActionCommand("Equilateral");
		// vordhaarne
		JRadioButton isoscelesTriangle = new JRadioButton("Isosceles");
		isoscelesTriangle.setActionCommand("Isosceles");

		JRadioButton scaleneTriangle = new JRadioButton("Scalene");
		scaleneTriangle.setActionCommand("Scalene");
		
		JRadioButton rightTriangle = new JRadioButton("Right");
		rightTriangle.setActionCommand("Right");

		group.add(equilateralTriangle);
		group.add(isoscelesTriangle);
		group.add(scaleneTriangle);
		group.add(rightTriangle);

		abLbl = new JLabel("Length of |AB|");
		bcLbl = new JLabel("Length of |BC|");
		caLbl = new JLabel("Length of |CA|");
		abHeightLbl = new JLabel("Height from base AB");
		bcHeightLbl = new JLabel("Height from base BC");
		caHeightLbl = new JLabel("Height from base CA");
		cabAngleLbl = new JLabel("Angle " + "\u2220CAB");
		abcAngleLbl = new JLabel("Angle " + "\u2220ABC");
		bcaAngleLbl = new JLabel("Angle " + "\u2220BCA");
		circumfLbl = new JLabel("Circumference");
		areaLbl = new JLabel("Area ");

		abInput = new JTextField(abLength == 0 ? "N/A" : "" + abLength);
		bcInput = new JTextField(bcLength == 0 ? "N/A" : "" + bcLength);
		caInput = new JTextField(caLength == 0 ? "N/A" : "" + caLength);
		abHeightInput = new JTextField(abHeight == 0 ? "N/A" : "" + abHeight);
		bcHeightInput = new JTextField(bcHeight == 0 ? "N/A" : "" + bcHeight);
		caHeightInput = new JTextField(caHeight == 0 ? "N/A" : "" + caHeight);
		cabAngleInput = new JTextField(cabAngle == 0 ? "N/A" : "" + cabAngle);
		abcAngleInput = new JTextField(abcAngle == 0 ? "N/A" : "" + abcAngle);
		bcaAngleInput = new JTextField(bcaAngle == 0 ? "N/A" : "" + bcaAngle);
		circumfInput = new JTextField(circumference == 0 ? "N/A" : "" + circumference);
		areaInput = new JTextField(area == 0 ? "N/A" : "" + area);
		abInput.setEditable(false);
		bcInput.setEditable(false);
		caInput.setEditable(false);
		abHeightInput.setEditable(false);
		bcHeightInput.setEditable(false);
		caHeightInput.setEditable(false);
		cabAngleInput.setEditable(false);
		abcAngleInput.setEditable(false);
		bcaAngleInput.setEditable(false);
		circumfInput.setEditable(false);
		areaInput.setEditable(false);

		this.add(equilateralTriangle);
		this.add(isoscelesTriangle);
		this.add(scaleneTriangle);
		this.add(rightTriangle);
		this.add(abLbl);
		this.add(abInput);
		this.add(bcLbl);
		this.add(bcInput);
		this.add(caLbl);
		this.add(caInput);
		this.add(abHeightLbl);
		this.add(abHeightInput);
		this.add(bcHeightLbl);
		this.add(bcHeightInput);
		this.add(caHeightLbl);
		this.add(caHeightInput);
		this.add(cabAngleLbl);
		this.add(cabAngleInput);
		this.add(abcAngleLbl);
		this.add(abcAngleInput);
		this.add(bcaAngleLbl);
		this.add(bcaAngleInput);
		this.add(circumfLbl);
		this.add(circumfInput);
		this.add(areaLbl);
		this.add(areaInput);
		equilateralTriangle.setEnabled(false);
		isoscelesTriangle.setEnabled(false);
		scaleneTriangle.setEnabled(false);
		rightTriangle.setEnabled(false);
		
		switch(guide){
		case 1:
			equilateralTriangle.setSelected(true);
			break;
		case 2:
			isoscelesTriangle.setSelected(true);
			break;
		case 3:
			scaleneTriangle.setSelected(true);
			break;
		case 4:
			rightTriangle.setSelected(true);
			break;
		}
		
		
		
		
	}
}
